<template>
	<view>
		
		<view class="search-box">
			<view style="display: flex; flex: 1; flex-direction: row;">
				<u-search :style="{flex:1}" placeholder="请输入认证编号" v-model="keyword" @search="search" @confirm="search" :showAction="false"></u-search>
			</view>
		</view>
		<view class="scanlog-list" v-for="(item,key) in list" @click="info(item)">
			<view class="log-top u-border-bottom">
				<text>{{item.supplier.supplier_name}}</text><text>{{item.order_sn}}</text>
			</view> 
			<view class="log-bottom">
				<view> 
					<text style="margin-bottom: 20rpx; line-height: 1.5;">商品：{{item.goods_name}}</text>
					<text>购买时间：{{$u.timeFormat(item.create_time,'yyyy年mm月dd日 hh时MM分ss秒')}}</text>
				</view>
			</view>
		</view>
		
	</view>
</template>
<script>
	export default {
		data() {
			return {
				keyword:"",
				calendarShow:false,
				
				loadStatus:"loadmore",
				currentPageNumber:1,
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				list:[],
				starttime:"",
				endtime:""
			}
		},
		onLoad(){
			this.getDatas();
		},
		methods: {
			info(e){
				uni.navigateTo({
					url:"/pages/order/detail?id=" + e.id
				})
			},
			search(){
				this.list = [];
				this.currentPageNumber = 1;
				this.loadStatus = 'loadmore';
				this.getDatas();
			},
			confirm(e){
				console.log(e); 
				this.starttime = e.startDate;
				this.endtime = e.endDate;
				this.list = [];
				this.currentPageNumber = 1;
				this.loadStatus = 'loadmore';
				this.getDatas();
				
			},
			getDatas(){
				if (this.loadStatus == "loading" || this.loadStatus == "nomore") return;
				this.loadStatus = "loading";
				this.$u.http.get("order/order/my",{
					page:this.currentPageNumber,
					starttime:this.starttime,
					endtime:this.endtime,
					keyword:this.keyword
				}).then(res => {
					// console.log(res);
					for(var i = 0; i<res.data.list.length; i++){
						var item = res.data.list[i];
						this.list.push(item);
					}
					if(res.data.list.length > 0){
						this.currentPageNumber ++;
						this.loadStatus = "loadmore";
					}else{
						this.loadStatus = "nomore";
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	
	.scanlog-list{
		display: flex;
		flex-direction: column;
		margin: 32rpx;
		padding:0;
		background-color: #FFFFFF;
		border-radius: 16rpx;
		overflow: hidden;
		.log-top{
			height: 94rpx;
			line-height: 94rpx;
			padding: 0 32rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
		}
		.log-bottom{
			display: flex;
			flex-direction: row;
			margin: 32rpx;
			view{
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				flex: 1;
				text{
					font-size: 24rpx;
					color: #666666;
				}
			}
			image{
				width: 78rpx; height:78rpx;
			}
		}
	}
	
	.search-box{
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: #FFFFFF;
		padding: 24rpx;
		> image{
			width: 40rpx;
			height: 40rpx;
			margin-left: 24rpx;
		}
	}
	
	.goods-list{
		display: flex;
		flex-direction: row;
		margin-top: 18rpx;
		margin-bottom: 18rpx;
		.goods{
			margin-right: 10rpx;
			.goods-thumbnail{
				width: 170rpx;
				height: 144rpx;
				background-color: #F2F2F2;
			}
			.goods-name{
				margin: 12rpx 0;
			}
		}
		.goods:nth-last-of-type(1){
			margin-right: 0;
		}
	}
</style>